package com.tmc.dao.impl.inthotel;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.tmc.dao.impl.BaseDaoImpl;
import com.tmc.entity.inthotel.ToHotelTbl;

@Repository
public class ToHotelTblDaoImpl extends BaseDaoImpl {
	
	public ToHotelTbl getUniqueHotelInfo(String hotelName){
		Session session = getSession();
		String hql = "from ToHotelTbl as ht where ht.hotelName = :hotelName";
		Query query = session.createQuery(hql);
		query.setString("hotelName", hotelName);
		List<ToHotelTbl> list =(List<ToHotelTbl>)query.list();
		session.close();
		if(list!=null&&list.size()!=0){
			return list.get(0);
		}
		return null;
	}
	
	public List<ToHotelTbl> getAllHotelInfo(){
		Session session = getSession();
		String hql = "from ToHotelTbl";
		Query query = session.createQuery(hql);
		List<ToHotelTbl> list =(List<ToHotelTbl>)query.list();
		session.close();
		return list;
	}
	
}
